package com.elcom.roaming.module.collection.match;

import com.elcom.roaming.common.StringCouple;
import com.elcom.roaming.common.db.cache.CacheInsert;
import com.elcom.roaming.common.util.match.Matching;
import com.elcom.roaming.common.util.match.ObjectInput;

public class UIMatching extends Matching{
	private CacheInsert cache;

	public UIMatching(CacheInsert cache) {
		this.cache = cache;
	}

	@Override
	public void forward(ObjectInput obj) {
		UIValue value = (UIValue) obj.getValue();
		UIValue dropValue = (UIValue) obj.getDropValue();
		
		if (value.getType() == dropValue.getType()) {
			return ;
		}
		
		StringCouple couple = null;
		if (value.isIMSI()) couple = new StringCouple(StringCouple.TYPE_IMSI, value.getNumber(), StringCouple.TYPE_MSISDN, dropValue.getNumber());
		else couple = new StringCouple(StringCouple.TYPE_IMSI, dropValue.getNumber(), StringCouple.TYPE_MSISDN, value.getNumber());
		
		logger.info("Forward to cache queue: " + obj.toString());
		cache.put(couple);
	}

}
